<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

<script type="text/javascript" src="<c:url value='/js/includes/prototype.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/scriptaculous/scriptaculous.js?load=builder,effects'/>"></script>
<script type="text/javascript" src="<c:url value='/js/includes/modalbox.js'/>"></script>

<style type="text/css">
    @import url( "<c:url value='/css/modalbox.css'/>" );
</style>

<logic:notEmpty name="transaction" property="transactions">
    <table width="100%">
        <tr>
            <td>
                <input type="button" value="<bean:message key='modal.add.transaction.payment.amex'/>"
                       class="transbutton"
                       onclick="Modalbox.show('<c:url value="/payment.do?type=1"/>'+'&rnd='+Math.random()*99999, {title: this.value, width: 600, height:300});return false;"/>
                <input type="button" value="<bean:message key='modal.add.transaction.payment.visa'/>"
                       class="transbutton"
                       onclick="Modalbox.show('<c:url value="/payment.do?type=2"/>'+'&rnd='+Math.random()*99999, {title: this.value, width: 600, height:300});return false;"/>
                <input type="button" value="<bean:message key='modal.add.transaction.payment.mastercard'/>"
                       class="transbutton"
                       onclick="Modalbox.show('<c:url value="/payment.do?type=3"/>'+'&rnd='+Math.random()*99999, {title: this.value, width: 600, height:300});return false;"/>
                <input type="button" value="<bean:message key='modal.add.transaction.payment.cheque'/>"
                       class="transbutton"
                       onclick="Modalbox.show('<c:url value="/payment.do?type=4"/>'+'&rnd='+Math.random()*99999, {title: this.value, width: 600, height:300});return false;"/>
                <input type="button" value="<bean:message key='modal.add.transaction.payment.cache'/>"
                       class="transbutton"
                       onclick="Modalbox.show('<c:url value="/payment.do?type=5"/>'+'&rnd='+Math.random()*99999, {title: this.value, width: 600, height:300});return false;"/>
                <input type="button" value="<bean:message key='modal.add.transaction.payment.giftcard'/>"
                       class="transbutton"
                       onclick="Modalbox.show('<c:url value="/payment.do?type=6"/>'+'&rnd='+Math.random()*99999, {title: this.value, width: 600, height:300});return false;"/>
            </td>
        </tr>
    </table>
</logic:notEmpty>
<table width="100%" class="checkout">
    <thead>
        <tr>
            <th><bean:message key="add.transaction.table.trans.key"/></th>
            <th><bean:message key="add.transaction.table.employee"/></th>
            <th><bean:message key="add.transaction.table.service.or.product"/></th>
            <th><bean:message key="add.transaction.table.quantity"/></th>
            <th><bean:message key="add.transaction.table.price"/></th>
            <th><bean:message key="add.transaction.table.taxes"/></th>
            <th><bean:message key="add.transaction.table.total"/></th>
            <th><bean:message key="add.transaction.table.action"/></th>
        </tr>
    </thead>
    <logic:notEmpty name="transaction" property="transactions">
        <tbody>
            <logic:iterate id="trans" name="transaction" property="transactions">
                <tr>
                    <td><bean:write name="trans" property="transNumber"/></td>
                    <td>
                        <logic:notEmpty name="trans" property="employee">
                            <bean:write name="trans" property="employee.firstName"/>&nbsp;
                            <bean:write name="trans" property="employee.lastName"/>
                        </logic:notEmpty>
                    </td>
                    <td align="center">
                        <logic:notEmpty name="trans" property="service">
                            <bean:write name="trans" property="service.name"/>
                        </logic:notEmpty>
                        <logic:notEmpty name="trans" property="product">
                            <bean:write name="trans" property="product.name"/>
                        </logic:notEmpty>
                        <logic:notEmpty name="trans" property="giftcardBean">
                            <bean:write name="trans" property="giftcardBean.name"/>
                        </logic:notEmpty>
                    </td>
                    <td><bean:write name="trans" property="quantity"/></td>
                    <td><bean:write name="trans" property="price" formatKey="usd.money.format"/></td>
                    <td><bean:write name="trans" property="taxes" formatKey="usd.money.format"/></td>
                    <td><bean:write name="trans" property="total" formatKey="usd.money.format"/></td>
                    <td>
                        <html:link action="/transaction" paramId="delete" paramName="trans" paramProperty="transNumber">
                            <bean:message key="add.transaction.table.action.delete"/>
                        </html:link>
                    </td>
                </tr>
            </logic:iterate>
        </tbody>
    </logic:notEmpty>
    <tfoot>
        <tr>
            <td rowspan="2" colspan="2">
                <bean:message key="add.transaction.table.footer.total"/>
            </td>
            <td colspan="6">
                <table width="100%">
                    <tr>
                        <td>
                            <bean:message key="add.transaction.table.without.taxes"/>
                            <bean:write name="transaction" property="totalPrice" formatKey="usd.money.format"/>
                        </td>
                        <td>
                            <bean:message key="add.transaction.table.taxes.only"/>
                            <bean:write name="transaction" property="totalTaxes" formatKey="usd.money.format"/>
                        </td>
                        <td>
                            <bean:message key="add.transaction.table.total.price"/>
                            <bean:write name="transaction" property="totalPriceAndTaxes" formatKey="usd.money.format"/>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </tfoot>
</table>

<fmt:bundle basename="ApplicationResources">
    <logic:messagesPresent message="true">
        <ul>
            <html:messages id="message" message="true" header="font.color.green.begin" footer="font.color.green.end">
                <li>
                    <c:out value="${message}"/>
                </li>
            </html:messages>
        </ul>
    </logic:messagesPresent>
    <logic:messagesPresent>
        <ul>
            <html:messages id="error" header="font.color.red.begin" footer="font.color.red.end">
                <li>
                    <c:out value="${error}"/>
                </li>
            </html:messages>
        </ul>
    </logic:messagesPresent>
</fmt:bundle>


